import $api from '@/http/interface'

// 路由守卫
const beforeEnter = (to, from, next) => {
  let token = window.localStorage.getItem('user-token')
  if (!token) {
    window.location.href = $api.oauthPath()
    return
  }
  next()
}
const routes = [
  {
    path: '/contrast-of-compliance',
    name: 'contrast-of-compliance',
    meta: { layout: 'admin', title: '合规性对比' },
    redirect: '/contrast-of-compliance/contrast',
    component: () => import('@/modules/contrast-of-compliance/views/index.vue'),
    children: [
      {
        path: 'contrast',
        name: 'contrast',
        meta: { layout: 'admin', title: '对比历史结果1111' },
        beforeEnter: beforeEnter,
        component: () => import('@/modules/contrast-of-compliance/views/contrast-of-compliance.vue')
      },
      {
        path: 'history',
        name: 'history',
        meta: { layout: 'admin', title: '对比历史结果' },
        beforeEnter: beforeEnter,
        component: () => import('@/modules/contrast-of-compliance/views/history-results.vue')
      }
    ]
  }
]

function mount () {
  this.$router.addRoutes(routes)
}

export default {
  mount
}
